package lcr;

import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;

public class Test0031 {
}

class Solution0031_1 {
    class LRUCache extends LinkedHashMap<Integer, Integer> {

        int capacity;

        public LRUCache(int capacity) {
            super(16, 1, true);
            this.capacity=capacity;
        }

        public int get(int key) {
            return getOrDefault(key,-1);
        }

        public void put(int key, int value) {
            super.put(key,value);
        }

        @Override
        protected boolean removeEldestEntry(Map.Entry<Integer, Integer> eldest) {

            return size()>capacity;
        }
    }
}
